package com.qsmx.store.app.main.mem;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.qsmx.store.app.R;
import com.qsmx.store.app.R2;
import com.qsmx.store.core.delegates.AtmosDelegate;

import butterknife.BindView;
import butterknife.OnClick;

public class MemCardPropertySearchDelegate extends AtmosDelegate {

    @BindView(R2.id.tv_coin_info)
    AppCompatTextView tvCoinInfo;
    @BindView(R2.id.tv_ticket_info)
    AppCompatTextView tvTicketInfo;
    @BindView(R2.id.tv_point_info)
    AppCompatTextView tvPointInfo;
    @BindView(R2.id.tv_do_info)
    AppCompatTextView tvDoInfo;
    @BindView(R2.id.tv_mem_do_time)
    AppCompatTextView tvMemDoTime;
    @BindView(R2.id.tv_mem_num)
    AppCompatTextView tvMemNum;
    @BindView(R2.id.cb_check_do_time)
    AppCompatCheckBox cbCheckDoTime;
    @BindView(R2.id.cb_store_date)
    AppCompatCheckBox cbStoreDate;

    @OnClick(R2.id.tv_coin_info)
    void onCoin() {
        onSetTitleCheckBg(tvCoinInfo);
        getSupportDelegate().replaceChildFragment(new MemCardPropertySearchCoinDelegate(), false);
    }

    @OnClick(R2.id.tv_ticket_info)
    void onTicket() {
        onSetTitleCheckBg(tvTicketInfo);
        getSupportDelegate().replaceChildFragment(new MemCardPropertySearchTicketDelegate(), false);
    }

    @OnClick(R2.id.tv_point_info)
    void onPoint() {
        onSetTitleCheckBg(tvPointInfo);
        getSupportDelegate().replaceChildFragment(new MemCardPropertySearchPointDelegate(), false);
    }

    @OnClick(R2.id.tv_do_info)
    void onDoInfo() {
        onSetTitleCheckBg(tvDoInfo);
        getSupportDelegate().replaceChildFragment(new MemCardPropertySearchDoInfoDelegate(), false);
    }

    @Override
    public Object setLayout() {
        return R.layout.delegate_mem_card_property_search;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        onSetTitleCheckBg(tvCoinInfo);
        getSupportDelegate().loadRootFragment(R.id.delegate_container, new MemCardPropertySearchCoinDelegate());
    }

    public void onSetTitleCheckBg(AppCompatTextView tv) {
        tvCoinInfo.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_corner_gary_title));
        tvTicketInfo.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_corner_gary_title));
        tvPointInfo.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_corner_gary_title));
        tvDoInfo.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_corner_gary_title));

        tvCoinInfo.setTextColor(getResources().getColor(R.color.theme_black));
        tvTicketInfo.setTextColor(getResources().getColor(R.color.theme_black));
        tvPointInfo.setTextColor(getResources().getColor(R.color.theme_black));
        tvDoInfo.setTextColor(getResources().getColor(R.color.theme_black));

        tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.round_corner_title_green_bg));
        tv.setTextColor(getResources().getColor(R.color.theme_white));
    }
}
